package com.yanqu.road.server.cmd.player;


import com.yanqu.road.message.YanQuMessage;
import com.yanqu.road.pb.winery.WineryProto;
import com.yanqu.road.server.cmd.CrossCommand;
import com.yanqu.road.server.command.Cmd;
import com.yanqu.road.server.logic.MessageHelper;
import com.yanqu.road.server.protocol.Protocol;
import com.yanqu.road.utils.YanQuMessageUtils;

@Cmd(code = Protocol.C_CROSS_WINERY_VISIT, desc = "跨服拜访玩家酒坊")
public class CrossWineryVisitCmd extends CrossCommand {

    private WineryProto.WineryVisitReqMsg reqMsg;

    private WineryProto.WineryVisitRespMsg.Builder respMsgBuilder;
    @Override
    public boolean parseData(YanQuMessage packet) throws Exception {
        this.reqMsg = WineryProto.WineryVisitReqMsg.parseFrom(packet.getBytes());
        return true;
    }

    @Override
    public void execute(YanQuMessage packet) throws Exception {
        WineryProto.CrossWineryVisitReqMsg.Builder builder = WineryProto.CrossWineryVisitReqMsg.newBuilder();
        builder.setUserId(packet.getPlayerId());
        builder.setServerId(this.serverId);
        builder.setVisitId(this.reqMsg.getVisitId());
        builder.setVisitServerId(this.reqMsg.getVisitServerId());
        YanQuMessage YanQuMessage = YanQuMessageUtils.buildMessage(Protocol.S_CROSS_TO_WINERY_VISIT, builder);
        MessageHelper.sendPacket(this.reqMsg.getVisitServerId(), this.reqMsg.getVisitId(), YanQuMessage);
    }

    @Override
    public void sendData() {

    }

    @Override
    public boolean isDebug() {
        return true;
    }

    @Override
    public String getRequestData() {
        return this.reqMsg.toString();
    }
}
